package com.smarttest.portal.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smarttest.common.beans.GeneralResultWithStatus;
import com.smarttest.common.beans.JsonDataResult;
import com.smarttest.portal.pojo.DbAutoEnvironment;
import com.smarttest.portal.service.AddInterfaceService;

@RequestMapping("/autog7")
@Controller
public class AddInterfaceController {
	@Autowired
	AddInterfaceService addInterfaceService;
	@RequestMapping(value = "/addInterface.action", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public GeneralResultWithStatus addInterface(HttpServletRequest request) {
		String intername = request.getParameter("intername");
		String params = request.getParameter("params");
		return GeneralResultWithStatus.okData(null, addInterfaceService.addInterface(intername, params));
	}
	@RequestMapping(value = "/getExistingInterface.action", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public GeneralResultWithStatus getExistingInterface(HttpServletRequest request) {
		String intername = request.getParameter("intername");
		return GeneralResultWithStatus.okData(null, addInterfaceService.getExistingInterface(intername));
	}
	@RequestMapping(value = "/getTestUrl.action", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public GeneralResultWithStatus getExistingInterface() {
		String s = addInterfaceService.getTestUrl();		
		return GeneralResultWithStatus.okData(null, s);
	}
	
	@RequestMapping(value = "/getTestUrlData.action", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public JsonDataResult getTestUrlData() {
		List<DbAutoEnvironment> result = addInterfaceService.getTestUrlData();		
		return JsonDataResult.ok(result);
	}
}
